#!/usr/bin/python
import MySQLdb as mdb

# Create a connection
db = mdb.connect("localhost", "testuser", "test123", "testdb")

# Prepare the cursor object using cursor method
cursor = db.cursor()

# Execute a SQL command or query.
cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method
data = cursor.fetchone()

# Creating an HTML output
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Database Version</title>'
print '</head>'
print '<body>'
print '<h2>Database Version: %s</h2>' % data
print '</body>'
print '</html>'
#print "Database version : %s " % data

# disconnect from server
db.close()
